import request from "@/utils/request";

import type {
  getTrademarkListRes,
  TrademarkModel,
  TrademarkListModel,
} from "./model/trademarkModel";

enum Api {
  getAllTrademarkList = "/admin/product/baseTrademark/getTrademarkList",
  getTrademarkList = "/admin/product/baseTrademark",
  saveTrademarkUrl = "/admin/product/baseTrademark/save",
  deleteTrademark = "/admin/product/baseTrademark/remove",
  updateTrademark = "/admin/product/baseTrademark/update",
}

/**
 *
 * @param page
 * @param limit
 * @returns
 */
//获取分页列表
export const getTrademarkListApi = (page: number, limit: number) => {
  return request.get<any, getTrademarkListRes>(
    Api.getTrademarkList + `/${page}/${limit}`
  );
};

// export const getTrademarkListApi = (page, limit) => {
//   return request.get(`/admin/product/baseTrademark/${page}/${limit}`);
// };

/**
 *
 * @param taName
 * @param logoUrl
 * @returns null
 */

//添加品牌

export const saveTrademarkApi = (tmName: string, logoUrl: string) => {
  return request.post<any, null>(Api.saveTrademarkUrl, { tmName, logoUrl });
};

/**
 *
 * @param id
 * @returns
 */

//删除品牌
export const removeTrademarkApi = (id: number) => {
  return request.delete<any, null>(Api.deleteTrademark + `/${id}`);
};

//修改品牌
export const updateTrademarkApi = (tm: TrademarkModel) => {
  return request.put<any, null>(Api.updateTrademark, tm);
};

//获取所有品牌数据
export const getAllTrademarkListApi = () => {
  return request.get<any, TrademarkListModel>(Api.getAllTrademarkList);
};
